package com.dididoctor.patient.Activity.Usercentre.Combo;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.dididoctor.patient.Activity.Service.ServiceDetail.ServiceDetailActivity;
import com.dididoctor.patient.Activity.Service.ServiceDetail.ServiceDetailPayActivity;
import com.dididoctor.patient.MV.adapter.CommonAdapter;
import com.dididoctor.patient.MV.adapter.ViewHolder;
import com.dididoctor.patient.R;
import com.dididoctor.patient.Utils.LoaderImage;
import com.dididoctor.patient.Utils.UserHeadImage;

import java.util.List;

/**
 * Created by Administrator on 2016/4/15.
 */
public class ComboAdapter extends CommonAdapter<ComboBean> {

    private UserHeadImage headImage;
    private TextView tv_name, tv_description, tv_date;
    private RelativeLayout rel_detail;
    private LoaderImage loaderImage;
    private Context context;

    public ComboAdapter(Context context, List<ComboBean> datas) {
        super(context, datas, R.layout.item_combo);
        loaderImage = new LoaderImage(context);
        this.context = context;
    }

    @Override
    public void convert(int position, ViewHolder helper, final ComboBean item) {
        headImage = helper.getView(R.id.user_image);
        loaderImage.load(headImage, item.getPicUrl());
        tv_name = helper.getView(R.id.tv_name);
        tv_name.setText(item.getName());
        tv_description = helper.getView(R.id.tv_description);
        tv_description.setText(item.getDescription());
        tv_date = helper.getView(R.id.tv_date);
        tv_date.setText(item.getStartTime());
        rel_detail = helper.getView(R.id.rel_detail);
        rel_detail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, ServiceDetailPayActivity.class);
                intent.putExtra("webUrl",item.getWebUrl());
                context.startActivity(intent);
            }
        });
    }
}
